import React, { Component } from "react";
import { context } from "./context";
class Children extends Component {
  list(txt) {
    console.log(txt);
  }
  // 第二种
  // static contextType = context;

  // 第一种
  componentDidMount() {
    const { genders } = this.context;
  }
  render() {
    const { genders } = this.context;
    // console.log(this.context);
    return (
      <>
        {genders}++
        <context.Consumer>
          {(value) => {
            return (
              <b>
                {this.list(value.base)}
                {value.base.genders}
                {value.left()}
                {value.com()}
                {value.callback("fn")}
              </b>
            );
          }}
        </context.Consumer>
      </>
    );
  }
}

// 第三种
// Children.contextType = context;
export default Children;
